package com.hymall.controller.wx;

import com.hymall.bean.MarketFeedback;
import com.hymall.bean.common.BaseRespVo;
import com.hymall.service.wx.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 牟治宇
 * @description 建议反馈
 * @date: 2022/7/19 9:36
 */

@RestController
@RequestMapping("/wx/feedback")
public class WxFeedbackController {

    @Autowired
    FeedbackService feedbackService;


    /**
     * @author 牟治宇
     * @description 反馈提交
     * @date 2022/7/19 16:53
     * @param [marketFeedback, userId]
     * @return com.hymall.bean.common.BaseRespVo
     */
    @PostMapping("/submit")
    public BaseRespVo wxSumbit(@RequestBody MarketFeedback marketFeedback,Integer userId){
        String mobile = marketFeedback.getMobile();
        if (mobile.trim().length() != 11 || mobile.matches("^1[3-9]\\\\d{9}$")) {
            return BaseRespVo.error(402, "手机号格式错误");
        }
        feedbackService.insertFeedback(marketFeedback,1);
        return BaseRespVo.ok();
    }
}
